home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
crypt
/
tarchiv
/
time2sec.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-01-27
|
1KB
|
61 lines
Program Test;
Uses DOS;
Function Date2Sec (Year, Month, Day, Hour, Minute, Second : Word) : Longint;
Var
M,D,Y,C,YA,J,Seconds : Longint;
Begin
Seconds := Hour*3600+Minute*60+Second;
Y := Year;
M := Month;
D := Day;
If (M>2) Then DEC (M,3) Else Begin INC(M,9); DEC(Y); End;
C := Y DIV 100;
YA := Y-(100*C);
J := (146097*C) DIV 4 + (1461*YA) DIV 4 + (153*M + 2) DIV 5 + D + 1721119;
If Seconds<12*3600 Then Begin
DEC(J);
INC(Seconds,12*3600);
End Else
DEC(Seconds,12*3600);
Date2Sec := (J*3600)*24+Seconds;
End;
Function Time2Sec : Longint;
Var
A,B,C,D,E,F,G,H : Word;
Begin
GetTime (A,B,C,D);
GetDate (E,F,G,H);
Time2Sec := Date2Sec (E,F,G,A,B,C);
End;
{ Procuce 10 char - octal string from integer }
Function OctalStr (X:Longint) : String;
Var
D : Longint;
S : String[10];
L : Byte;
Begin
D := X;
{ Convert to octal }
S[0] := #10;
For L := 10 DownTo 1 Do Begin
S[L] := Chr(48+(D AND 7));
D := D SHR 3;
End;
{ Remove leading zeros }
L := 1;
While (S[L]='0') AND (L<11) Do Begin
S[L] := ' ';
INC(L);
End;
OctalStr := S;
End;
Begin
Writeln (OctalStr(Time2Sec-Date2Sec(1970,1,1,0,0,0)));
Readln;
End.